//
//  MeVCTbvTypeCellView.m
//  ZITHER
//
//  Created by weixin on 2019/1/15.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "MeVCTbvTypeCellView.h"
#import "Ugc_HomePage_VC_V3.h"
#import "MyInterestVC.h"
#import "Ugc_MyLaud_VC.h"
#import "Main_CollectWatch_WX_VC.h"


@implementation MeVCTbvTypeCellView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        [self createBtn];
        [self defaultConfiguration];
        
        [self addSubview:self.btnPackUp];
        
        [self.btnPackUp mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(0);
            make.centerX.equalTo(self).offset(0);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(300);
        }];
        
    }
    return self;
}

-(void)defaultConfiguration{
    self.backgroundColor = [UIColor whiteColor];
    [self setShadowRadiusWithColor:[UIColor colorWithHex:@"000000"] offset:CGSizeZero opacity:0.1 radius:10];
}

-(void)createBtn{
//        NSArray *arrImage = @[@"我的_我的关注",@"我的_我的点赞",@"我的_我的创作"];
//        NSArray *arrTitle = @[@"我的关注",@"我的点赞",@"我的创作"];
    NSArray *arrImage = @[@"我的_我的关注",@"我的_我的点赞",@"我的_我的创作",@"我的_我的追踪"];
    NSArray *arrTitle = @[@"我的关注",@"我的点赞",@"我的创作",@"我的追踪"];
    
    for (int i = 0; i<arrTitle.count; i++) {
        BaseBtn *btn = [[BaseBtn alloc]initializeFrame:CGRectMake((kScreenW-30)/3.0*(i%3), 70*(i/3), (kScreenW-30)/3.0, 70) NormalImage:arrImage[i] SeleImage:@""];
        
        
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
            btn.frame = CGRectMake((kScreenW-30)/3.0*(i%3), 70*(i/3), (kScreenW-30)/3.0, 70);
        }else{
            btn.frame = CGRectMake((kScreenW-30)/3.0*(i%3), 70*(i/3), (kScreenW-30)/3.0, 70);
        }

        [btn setTitle:arrTitle[i] forState:UIControlStateNormal];
        [btn setCornerRadiusWithRadius:10 isMasks:YES];
        [btn setTitleColor:[UIColor colorWithHex:@"333333"] forState:UIControlStateNormal];
        btn.titleLabel.font  = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
        btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示
        [self addSubview:btn];
        btn.tag = 101+i;
        btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示
        
        btn.imageEdgeInsets = UIEdgeInsetsMake(-11,27,11,-27);//图片距离右边框距离减少图片的宽度，其它不边
        btn.titleEdgeInsets = UIEdgeInsetsMake(13,-8,-13,8);//文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变
        @weakify(self);
        [[btn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            [self cellClick:btn.tag-100];
        }];
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
            [btn setTitleColor:Main_Token_Model_MANAGER.navTitleColor forState:UIControlStateSelected];
        }else{
            [btn setTitleColor:[UIColor colorWithHex:@"333333"] forState:UIControlStateSelected];
        }
        if (i == 3) {
            btn.hidden=YES;
        }

    }
    
}

-(void)cellClick:(NSInteger)index{
    if (index == 1) {
        MyInterestVC *vc = [[MyInterestVC alloc]init];
        [self.getNav pushViewController:vc animated:YES];
    }else if (index == 2){
        Ugc_MyLaud_VC *vc = [[Ugc_MyLaud_VC alloc]init];
        [self.getNav pushViewController:vc animated:YES];
    }else if (index ==4){
        Main_CollectWatch_WX_VC *vc = [[Main_CollectWatch_WX_VC alloc]init];
        [self.getNav pushViewController:vc animated:YES];
    }else{
        Ugc_HomePage_VC_V3 *vc = [[Ugc_HomePage_VC_V3 alloc]init];
        vc.userName = kUSER_INFO_MANAGER.nickName;
        vc.userId = kUSER_INFO_MANAGER.userId;
        vc.userAvatar = kUSER_INFO_MANAGER.avatar;
        [self.getNav pushViewController:vc animated:YES];
    }
}



- (BaseBtn *)btnPackUp{
    if (!_btnPackUp) {
        _btnPackUp = [BaseBtn initCustomBtn:@[@"我的_icon_下拉",@"我的_icon_收起"]];
        _btnPackUp.backgroundColor = [UIColor clearColor];
    }
    return _btnPackUp;
}

@end
